package com.gm.controller;

import com.gm.entity.Department;
import com.gm.mapper.DeptMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author Administrator
 * @Date 2020/6/17 16:05
 **/
@RestController
public class DeptController {
    @Autowired
    DeptMapper deptMapper;

    //增加
    @GetMapping("/dept")
    public Department addDept(Department department){
        deptMapper.addDept(department);
        return department;
    }
    //查询
    @GetMapping("/dept/{id}")
    public Department getDeptById(@PathVariable("id") Integer id){
        return deptMapper.getDeptById(id);
    }
    //删除
    @DeleteMapping("/dept/{id}")
    public int delDept(@PathVariable("id") Integer id){
        return deptMapper.delDept(id);
    }
    //修改
    @PutMapping("/dept")
    public int updDept(Department department){
        return deptMapper.updDept(department);
    }
}
